package com.itlong.cloud.service.impl;

import com.itlong.cloud.POJO.PO.OperationLogPO;
import com.itlong.cloud.PlatformConstants;
import com.itlong.cloud.dao.IUserOperationLogDao;
import com.itlong.cloud.service.IUserOperationLogService;
import com.itlong.cloud.utils.data.handler.SqlUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.Map;

/**
 * <desc>
 *      操作日志业务处理接口实现类
 * </desc>
 *
 * @createDate 2018/05/02
 */
@Service
public class UserOperationLogServiceImpl implements IUserOperationLogService {

    @Autowired
    private IUserOperationLogDao iUserOperationLogDao;

    /**
     * <desc>
     *      保存日志
     * </desc>
     *
     * @param operationLogPO 操作日志实体类
     * @return sql执行行数
     * @author wangzhi
     * @createDate 2018/05/02
     */
    @Override
    public Integer save(OperationLogPO operationLogPO) throws Exception {
        return iUserOperationLogDao.save(SqlUtil.durableData(operationLogPO, PlatformConstants.TABLE_SAVE));
    }

    /**
     * <desc>
     *      保存开发者访问日志
     * </desc>
     *
     * @param map 日志信息
     * @return
     * @author wangzhi
     * @createDate 2018/12/19
     */
    @Override
    @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED)
    public Integer saveDeveloperLog(Map<String, Object> map) throws Exception {
        return iUserOperationLogDao.saveDeveloperLog(map);
    }

    /**
     * <desc>
     *      保存开发者异常日志
     * </desc>
     *
     * @param map 日志信息
     * @return
     * @author Qiang.S
     * @createDate 2019/09/18
     */
    @Override
    @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED)
    public Integer saveDeveloperExceptionLog(Map<String, Object> map) throws Exception {
        return iUserOperationLogDao.saveDeveloperExceptionLog(map);
    }
}
